'''
txt文件操作的方法：
read()
readline()
readlines()
'''
# 案例1：read() 返回值：str
# 适合文件复制
with open(r'username.txt') as f:
    data = f.read()
    print(data)
    print(type(data))

# 案例2：readline():读取每一行，如何实现？？？

with open(r'username.txt') as f:
    while True:
        line = f.readline()
        if line:
            print(line)
        else:
            break

# 案例3：readlines():
print('-----------------------')
with open(r'username.txt') as f:
    data_list = f.readlines()

for data in data_list:
    print(data.split(',')[0])
    print(data.split(',')[1])
